global root_path "/Volumes/Workgroup/Lab/Lab-heimb/Montenovo/Volunteering Paper/Data"

clear all
set maxvar 32767

cd "$root_path/02_ready_for_PSIDclean"


use individ_family_2011.dta, clear

cd "$root_path/03_ready_for_TAXSIM"

rename ER47302 family_id

gen unique_id_crossys=(ER30001*1000) + ER30002

gen sequence_num=ER34102


rename ER30000 release_number
rename ER30001 interview_number_1986
rename ER30002 person_number

gen white_w=0
replace white_w=1 if ER51810==1 & ER51811==0 & ER51812==0 & ER51813==0

gen black_w=0
replace black_w=1 if ER51810==2 & ER51811==0 & ER51812==0 & ER51813==0

gen native_amer_w=0
replace native_amer_w=1 if ER51810==3 & ER51811==0 & ER51812==0 & ER51813==0

gen asian_w=0
replace asian_w=1 if ER51810==4 & ER51811==0 & ER51812==0 & ER51813==0

*gen latino_w=0
*replace latino_w=1 if ER51810==5 & ER51811==0 & ER51812==0 & ER51813==0

gen other_w=0
replace other_w=1 if ER51810>=5
replace other_w=1 if ER51811!=0 | ER51812!=0 | ER51813!=0

gen any_race_w=white_w+black_w+native_amer_w+asian_w+other_w
sum any_race_w

*  3,721 have no recorded race in OUR data
*  3,524: no wife present
*  3,721-3,524 are mixed race so we did not code them yet

* husband
gen white_h=0
replace white_h=1 if ER51904==1 & ER51905==0 & ER51906==0 & ER51907==0

gen black_h=0
replace black_h=1 if ER51904==2 & ER51905==0 & ER51906==0 & ER51907==0

gen native_amer_h=0
replace native_amer_h=1 if ER51904==3 & ER51905==0 & ER51906==0 & ER51907==0

gen asian_h=0
replace asian_h=1 if ER51904==4 & ER51905==0 & ER51906==0 & ER51907==0

*gen latino_h=0
*replace latino_h=1 if ER51904==5 & ER51905==0 & ER51906==0 & ER51907==0

gen other_h=0
replace other_h=1 if ER51904>=5
replace other_h=1 if ER51905!=0 | ER51906!=0 | ER51907!=0

gen any_race_h=white_h+black_h+native_amer_h+asian_h+other_h
sum any_race_h

*  7,524 have no recorded race in OUR data
*  298: are mixed race so we did not code them yet

** State of residence.
rename ER47303 state_residence
rename ER47304 state_current

** RAW FIELDS.
** Marriage stuff.
rename ER47323 marital_status_head
rename ER52407 marital_status_generated
rename ER47318 sex_head

gen married=0
replace married=1 if marital_status_head==1

keep if (sequence_num==1 & married==0) | (sequence_num==1 & married==1) | (sequence_num==2 & married==1)


** Children.
rename ER47320 children
** Ages.
rename ER47317 age_head
rename ER47319 age_wife
rename ER47321 age_youngest_child

rename ER52240 dividend_inc_head_gen
rename ER52238 rent_inc_head_gen
rename ER52214 farm_inc_head_gen
rename ER52217 unincorp_assetpt_inc_head_gen

rename ER52280 alimony_inc_head_gen
rename ER52251 rent_inc_wife_gen
rename ER52247 unincorp_assetpt_inc_wife_gen
rename ER52259 taxable_inc_hh_gen
rename ER52249 labor_inc_wife_gen
rename ER52253 dividend_inc_wife_gen
rename ER52237 labor_inc_head_gen
rename ER52242 interest_inc_head_gen
rename ER52255 interest_inc_wife_gen
rename ER48863 alimony_given
rename ER52268 nonva_retire_inc_head_gen
rename ER52294 retire_annuities_inc_wife_gen
rename ER52337 socsec_inc_head_gen
rename ER52339 socsec_inc_wife_gen
rename ER52274 unemployment_inc_head_gen
rename ER52296 unemployment_inc_wife_gen
rename ER52262 ssi_inc_head_gen
rename ER52290 ssi_inc_wife_gen
rename ER52266 vapension_inc_head_gen
rename ER52276 workerscomp_inc_head_gen
rename ER52298 workerscomp_inc_wife_gen
rename ER52260 tanf_inc_head_gen
rename ER52288 tanf_inc_wife_gen
rename ER52264 otherwelfare_inc_head_gen
rename ER52292 otherwelfare_inc_wife_gen
rename ER52278 childsupport_inc_head_gen
rename ER52300 childsupport_inc_wife_gen
rename ER47387 rent_amount
rename ER47388 rent_amount_unit
rename ER47342 property_tax_annual
rename ER48850 itemized_charitable
rename ER48851 itemized_medical
rename ER48849 whether_itemized
rename ER47970 childcare_expense
rename ER47971 childcare_expense_unit
rename ER47348 mortgage1_principle_remaining
rename ER47355 mortgage1_interest_rate_wholenum
rename ER47356  mortgage1_interest_rate_fraction

////////////////////////////////////////////////////////////////////////////////

*donations

rename ER51959 whether_donation25_religious
rename ER51960 whether_donation_religious
rename ER51961 amount_donation_religious
rename ER51966 whether_donation_combo
rename ER51967 amount_donation_combo
rename ER51972 whether_donation_needy
rename ER51973 amount_donation_needy
rename ER51978 whether_donation_health
rename ER51979 amount_donation_health
rename ER51984 whether_donation_education
rename ER51985 amount_donation_education
rename ER51990 whether_donation_youth
rename ER51991 amount_donation_youth
rename ER51996 whether_donation_culture
rename ER51997 amount_donation_culture
rename ER52002 whether_donation_community
rename ER52003 amount_donation_community
rename ER52008 whether_donation_environment
rename ER52009 amount_donation_environment
rename ER52014 whether_donation_peace
rename ER52015 amount_donation_peace
rename ER52020 whether_donation_other
rename ER52021 amount_donation_other
rename ER52020A type_other_org

////////////////////////////////////////////////////////////////////////////////

*volunteering
rename ER52031 whether_volunteer_religious_hd
rename ER52032 whether_volunteer_youth_hd
rename ER52033 whether_volunteer_senior_hd
rename ER52034 whether_volunteer_health_hd
rename ER52035 whether_volunteer_needy_hd
rename ER52036 whether_volunteer_socchange_hd
rename ER52037 whether_volunteer_other_hd
rename ER52037A type_volunteer_hd

rename ER52049 whether_volunteer_religious_wf
rename ER52050 whether_volunteer_youth_wf
rename ER52051 whether_volunteer_senior_wf
rename ER52052 whether_volunteer_health_wf
rename ER52053 whether_volunteer_needy_wf
rename ER52054 whether_volunteer_socchange_wf
rename ER52055 whether_volunteer_other_wf
rename ER52055A type_volunteer_wf

rename ER47758 hr_wage_spouse
rename ER47501 hr_wage_hd
rename ER48241 tot_wage_hd
rename ER48615 tot_wage_spouse
rename ER52175 tot_hs_worked_head
rename ER52196 tot_hs_worked_spouse

rename ER51953 religion_hd
rename ER51859 religion_spouse
rename ER52399A rural

rename ER48499 whether_unemployed_head
rename ER48618 whether_unemployed_spouse

drop ER*

save fam2011er-small.dta, replace


